/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Gui;

import Params.ChatMessage;
import Params.ServerSocketItem;
import java.awt.Graphics;
import java.awt.Image;
import java.net.Socket;

/**
 *
 * @author Admin
 */
public class frmSreenClient extends javax.swing.JInternalFrame {

    /**
     * Creates new form frmSreenClient
     */
    Socket _sockhientai = null;
    boolean _stop = true;
    public frmSreenClient() {
        initComponents();
    }
frmSreenClient(String strPort, Socket temp) throws InterruptedException {
        initComponents();

        //initServer(strPort);
        _sockhientai = temp;
        int temp1 = (temp.getPort());
        this.title = "CAPTURE SCREEN - CLIENT " + temp1 + "";

        capturescreen();
    }
void capturescreen() throws InterruptedException {

        for (int i = 0; i < MainSever.listConnection.size(); i++) {
            ServerSocketItem temp = (ServerSocketItem) MainSever.listConnection.elementAt(i);
            Socket _tempsock = temp.getSOCK();
            if (_tempsock.getPort() == _sockhientai.getPort()) {

                temp.getConnectionSpy().bufferedWriter.println("Thong Bao Chup Hinh");
                temp.getConnectionSpy().bufferedWriter.flush();

                break;
            }


        }


    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jpane = new javax.swing.JScrollPane();

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        try {
            setSelected(true);
        } catch (java.beans.PropertyVetoException e1) {
            e1.printStackTrace();
        }
        setVisible(true);

        jScrollPane1.setViewportView(jpane);

        getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jpane;
    // End of variables declaration//GEN-END:variables
    void onRead(ChatMessage message) {
//        ImageIcon icon = (ImageIcon) message.getImg();
//        jimage.setIcon(icon);
        Image imgn = message.getImg().getImage();
        imgn = imgn.getScaledInstance(jpane.getWidth(), jpane.getHeight(), Image.SCALE_FAST);
        Graphics g = jpane.getGraphics();
        g.drawImage(imgn, 0, 0, jpane.getWidth(), jpane.getHeight(), jpane);

        for (int i = 0; i < MainSever.listConnection.size(); i++) {
            ServerSocketItem temp = (ServerSocketItem) MainSever.listConnection.elementAt(i);
            Socket _tempsock = temp.getSOCK();
            if (_tempsock.getPort() == _sockhientai.getPort()) {

                temp.getConnectionSpy().bufferedWriter.println("Thong Bao Chup Hinh");
                temp.getConnectionSpy().bufferedWriter.flush();

                break;
            }

        }
    }
}
